package com.bao.work.work04;


import java.util.ArrayList;

/**
 * @author baoye
 * @date 2024-07-29/19:02
 */
public class MainApp {
    public static void main(String[] args) {
        ArrayList<Student> sList = new ArrayList<>();
        sList.add(new Student("it001", "黄渤","男",20,1.72));
        sList.add(new Student("it002", "孙红雷","男",22, 1.78));
        sList.add(new Student("it003", "章子怡","女",18, 1.64));

        printStu(sList);

        System.out.println("最高的学生信息:\n"+heightStu(sList));
    }
    public static void printStu(ArrayList<Student> list){
        for (Student student : list) {
            System.out.println(student);
        }
    }
    public static Student heightStu(ArrayList<Student> list){
        Double max=list.get(0).getHeight();
        int index=0;
        for (Student student : list) {
            if(student.getHeight()>max){
                index=list.indexOf(student);
            }
        }
        return list.get(index);
    }
}
